# -*- makefile -*-
# Makefile for Borland C++ 

OBJS = class.obj compiler.obj database.obj xml.obj replicator.obj hashtab.obj file.obj sync.obj \
	symtab.obj btree.obj cursor.obj query.obj pagepool.obj \
	wwwapi.obj w32sock.obj blob.obj container.obj rtree.obj exception.obj localcli.obj server.obj

LIBOBJS = + class.obj + compiler.obj + xml.obj + sync.obj + database.obj + replicator.obj + hashtab.obj + file.obj + \
	symtab.obj + btree.obj + cursor.obj + query.obj + pagepool.obj + \
	wwwapi.obj + w32sock.obj + blob.obj + container.obj + rtree.obj + exception.obj + localcli.obj


CLI_OBJS = cli.obj w32sock.obj repsock.obj
CLI_LIBOBJS = + cli.obj + w32sock.obj + repsock.obj

INCS = gigabase.h stdtp.h class.h database.h cursor.h selection.h reference.h wwwapi.h array.h \
	file.h hashtab.h btree.h sync.h query.h datetime.h pagepool.h blob.h container.h rectangle.h timeseries.h config.h confdefs.h exception.h


GB_LIB = gigabase.lib
CLI_LIB = cli.lib

GB_DLL = gigabase.dll
CLI_DLL = cli.dll

EXES = subsql.exe cgistub.exe

EXAMPLES = guess.exe guess_std.exe guess2.exe testdb.exe testleak.exe testjoin.exe testddl.exe testperf.exe teststd.exe testperf2.exe testsync.exe testiref.exe testtrav.exe testidx.exe testidx2.exe bugdb.exe clidb.exe clitest.exe localclitest.exe testblob.exe testraw.exe testspat.exe testreplic.exe testtl.exe

CC = BCC32.EXE
# !!! DEFS macro is deprecated - edit config.h header file instead
DEFS =


CFLAGS = -c -Ox -w-8027 -DASM_CPUID_NOT_SUPPORTED $(DEFS)

LD = $(CC)
LDFLAGS = 

AR = tlib
ARFLAGS = 

STDLIBS =

SOCKLIBS =

all: $(GB_LIB) $(CLI_LIB) $(EXES) $(EXAMPLES)

class.obj: class.cpp compiler.h compiler.d symtab.h $(INCS)
	$(CC) $(CFLAGS) class.cpp

compiler.obj: compiler.cpp compiler.h compiler.d symtab.h $(INCS)
	$(CC) $(CFLAGS) compiler.cpp

sync.obj: sync.cpp sync.h stdtp.h
	$(CC) $(CFLAGS) sync.cpp

query.obj: query.cpp compiler.h compiler.d symtab.h $(INCS)
	$(CC) $(CFLAGS) query.cpp

database.obj: database.cpp compiler.h compiler.d symtab.h $(INCS)
	$(CC) $(CFLAGS) database.cpp

xml.obj: xml.cpp compiler.h compiler.d symtab.h $(INCS)
	$(CC) $(CFLAGS) xml.cpp

localcli.obj: localcli.cpp compiler.h compiler.d symtab.h localcli.h  $(INCS)
	$(CC) $(CFLAGS) localcli.cpp

replicator.obj: replicator.cpp replicator.h sockio.h $(INCS)
	$(CC) $(CFLAGS) replicator.cpp

cursor.obj: cursor.cpp compiler.h compiler.d $(INCS)
	$(CC) $(CFLAGS) cursor.cpp

hashtab.obj: hashtab.cpp $(INCS)
	$(CC) $(CFLAGS) hashtab.cpp

pagepool.obj: pagepool.cpp $(INCS)
	$(CC) $(CFLAGS) pagepool.cpp

file.obj: file.cpp $(INCS)
	$(CC) $(CFLAGS) file.cpp

symtab.obj: symtab.cpp symtab.h $(INCS)
	$(CC) $(CFLAGS) symtab.cpp

btree.obj: btree.cpp $(INCS)
	$(CC) $(CFLAGS) btree.cpp

rtree.obj: rtree.cpp $(INCS)
	$(CC) $(CFLAGS) rtree.cpp

exception.obj: exception.cpp $(INCS)
	$(CC) $(CFLAGS) exception.cpp

blob.obj: blob.cpp $(INCS)
	$(CC) $(CFLAGS) blob.cpp

container.obj: container.cpp $(INCS)
	$(CC) $(CFLAGS) container.cpp

wwwapi.obj: wwwapi.cpp wwwapi.h stdtp.h sockio.h sync.h
	$(CC) $(CFLAGS) wwwapi.cpp

w32sock.obj: w32sock.cpp w32sock.h sockio.h stdtp.h
	$(CC) $(CFLAGS) w32sock.cpp

repsock.obj: repsock.cpp repsock.h sockio.h stdtp.h sync.h
	$(CC) $(CFLAGS) repsock.cpp

cli.obj: cli.cpp cli.h cliproto.h repsock.h sockio.h stdtp.h sync.h
	$(CC) $(CFLAGS) cli.cpp


gigabase.lib: $(OBJS)
	$(AR) $(ARFLAGS) gigabase.lib $(LIBOBJS)

gigabase.dll: $(OBJS)
	$(CC) $(DLLFLAGS) /Fegigabase.dll $(OBJS) $(STDLIBS) $(SOCKLIBS)

cli.lib: $(CLI_OBJS)
	$(AR) $(ARFLAGS) cli.lib $(CLI_LIBOBJS)

cli.dll: $(CLI_OBJS)
	$(CC) $(DLLFLAGS) /Fecli.dll $(CLI_OBJS) $(STDLIBS) $(SOCKLIBS)

subsql.obj: subsql.cpp compiler.h server.h compiler.d subsql.h symtab.h $(INCS)
	$(CC) $(CFLAGS) subsql.cpp

server.obj: server.cpp compiler.h server.h compiler.d subsql.h symtab.h cliproto.h $(INCS)
	$(CC) $(CFLAGS) server.cpp

subsql.exe: subsql.obj $(GB_LIB)
	$(LD) $(LDFLAGS) subsql.obj $(GB_LIB) $(STDLIBS) $(SOCKLIBS)

clitest.obj: clitest.c cli.h
	$(CC) $(CFLAGS) clitest.c

clitest.exe: clitest.obj $(CLI_LIB)
	$(LD) $(LDFLAGS) clitest.obj $(CLI_LIB) $(STDLIBS) $(SOCKLIBS)


localclitest.exe: clitest.obj $(GB_LIB)
	$(LD) $(LDFLAGS) -elocalclitest.exe clitest.obj $(GB_LIB) $(STDLIBS)


bugdb.obj: bugdb.cpp bugdb.h $(INCS)
	$(CC) $(CFLAGS) bugdb.cpp

bugdb.exe: bugdb.obj  $(GB_LIB)
	$(LD) $(LDFLAGS) bugdb.obj $(GB_LIB) $(STDLIBS) $(SOCKLIBS)

clidb.obj: clidb.cpp clidb.h $(INCS)
	$(CC) $(CFLAGS) clidb.cpp

clidb.exe: clidb.obj  $(GB_LIB)
	$(LD) $(LDFLAGS) clidb.obj $(GB_LIB) $(STDLIBS) $(SOCKLIBS)


cgistub.obj: cgistub.cpp stdtp.h sockio.h
	$(CC) $(CFLAGS) cgistub.cpp

cgistub.exe: cgistub.obj
	$(LD) $(LDFLAGS) cgistub.obj $(GB_LIB) $(STDLIBS) $(SOCKLIBS)


guess.obj: guess.cpp $(INCS)
	$(CC) $(CFLAGS) guess.cpp

guess.exe: guess.obj $(GB_LIB)
	$(LD) $(LDFLAGS) guess.obj $(GB_LIB) $(STDLIBS)

guess_std.obj: guess_std.cpp $(INCS)
	$(CC) $(CFLAGS) guess_std.cpp

guess_std.exe: guess_std.obj $(GB_LIB)
	$(LD) $(LDFLAGS) guess_std.obj $(GB_LIB) $(STDLIBS)

guess2.obj: guess2.cpp $(INCS)
	$(CC) $(CFLAGS) guess2.cpp

guess2.exe: guess2.obj $(GB_LIB)
	$(LD) $(LDFLAGS) guess2.obj $(GB_LIB) $(STDLIBS)

testdb.obj: testdb.cpp $(INCS)
	$(CC) $(CFLAGS) testdb.cpp

testdb.exe: testdb.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testdb.obj $(GB_LIB) $(STDLIBS)

testraw.obj: testraw.cpp $(INCS)
	$(CC) $(CFLAGS) testraw.cpp

testraw.exe: testraw.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testraw.obj $(GB_LIB) $(STDLIBS)

testleak.obj: testleak.cpp $(INCS)
	$(CC) $(CFLAGS) testleak.cpp

testleak.exe: testleak.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testleak.obj $(GB_LIB) $(STDLIBS)

testjoin.obj: testjoin.cpp $(INCS)
	$(CC) $(CFLAGS) testjoin.cpp

testjoin.exe: testjoin.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testjoin.obj $(GB_LIB) $(STDLIBS)

testddl.obj: testddl.cpp $(INCS)
	$(CC) $(CFLAGS) testddl.cpp

testddl.exe: testddl.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testddl.obj $(GB_LIB) $(STDLIBS)

testblob.obj: testblob.cpp $(INCS)
	$(CC) $(CFLAGS) testblob.cpp

testblob.exe: testblob.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testblob.obj $(GB_LIB) $(STDLIBS)

testperf.obj: testperf.cpp $(INCS)
	$(CC) $(CFLAGS) testperf.cpp

testperf.exe: testperf.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testperf.obj $(GB_LIB) $(STDLIBS)

testtl.obj: testtl.cpp $(INCS)
	$(CC) $(CFLAGS) testtl.cpp

testtl.exe: testtl.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testtl.obj $(GB_LIB) $(STDLIBS)

testspat.obj: testspat.cpp $(INCS)
	$(CC) $(CFLAGS) testspat.cpp

testspat.exe: testspat.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testspat.obj $(GB_LIB) $(STDLIBS)

testreplic.obj: testreplic.cpp replicator.h $(INCS)
	$(CC) $(CFLAGS) testreplic.cpp

testreplic.exe: testreplic.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testreplic.obj $(GB_LIB) $(STDLIBS) $(SOCKLIBS)

teststd.obj: teststd.cpp $(INCS)
	$(CC) $(CFLAGS) teststd.cpp

teststd.exe: teststd.obj $(GB_LIB)
	$(LD) $(LDFLAGS) teststd.obj $(GB_LIB) $(STDLIBS)

testinc.obj: testinc.cpp $(INCS)
	$(CC) $(CFLAGS) testinc.cpp

testinc.exe: testinc.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testinc.obj $(GB_LIB) $(STDLIBS)

testperf2.obj: testperf2.cpp $(INCS)
	$(CC) $(CFLAGS) testperf2.cpp

testperf2.exe: testperf2.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testperf2.obj $(GB_LIB) $(STDLIBS)

testidx.obj: testidx.cpp $(INCS)
	$(CC) $(CFLAGS) testidx.cpp

testidx.exe: testidx.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testidx.obj $(GB_LIB) $(STDLIBS)

testidx2.obj: testidx2.cpp $(INCS)
	$(CC) $(CFLAGS) testidx2.cpp

testidx2.exe: testidx2.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testidx2.obj $(GB_LIB) $(STDLIBS)

testsync.obj: testsync.cpp $(INCS)
	$(CC) $(CFLAGS) testsync.cpp

testsync.exe: testsync.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testsync.obj $(GB_LIB) $(STDLIBS)

testiref.obj: testiref.cpp $(INCS)
	$(CC) $(CFLAGS) testiref.cpp

testiref.exe: testiref.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testiref.obj $(GB_LIB) $(STDLIBS)

testtrav.obj: testtrav.cpp $(INCS)
	$(CC) $(CFLAGS) testtrav.cpp

testtrav.exe: testtrav.obj $(GB_LIB)
	$(LD) $(LDFLAGS) testtrav.obj $(GB_LIB) $(STDLIBS)



cleanobj:
	-del *.odb,*.exp,*.obj,*.pch,*.pdb,*.ilk,*.dsp,*.dsw,*.ncb,*.opt,*.class
	-del javacli\*~,javacli\*.class,javacli\*.obj,javacli\*.lib,javacli\*.pdb,javacli\*.ilk,javacli\*.exp,javacli\*.jar
	-del jnicli\*~,jnicli\*.class,jnicli\*.obj,jnicli\*.lib,jnicli\*.pdb,jnicli\*.ilk,jnicli\*.exp,jnicli\*.jar

cleandbs:
	-del *.dbs

clean: cleanobj cleandbs
	-del *~,*.lib,*.dll,*.exe

java: javacli.jar jnicli.jar CliTest.class TestIndex.class JniTestIndex.class

javacli.jar: javacli\*.java
	javac -g javacli\*.java
	jar cvf javacli.jar javacli\*.class
	javadoc -d javacli/docs -public javacli\*.java

jnicli.jar: jnicli\*.java
	javac -g jnicli\*.java
	jar cvf jnicli.jar jnicli\*.class
	javadoc -d jnicli/docs -public jnicli\*.java

CliTest.class: CliTest.java javacli.jar
	javac -classpath .;javacli.jar CliTest.java

TestIndex.class: TestIndex.java javacli.jar
	javac -classpath .;javacli.jar TestIndex.java

JniTestIndex.class: JniTestIndex.java jnicli.jar
	javac -classpath .;jnicli.jar JniTestIndex.java

csharp: csharpcli.dll CSharpCliTest.exe

csharpcli.dll: csharpcli\*.cs
	csc /debug /doc:csharpcli\CSharpCLI.xml /t:library /out:csharpcli.dll csharpcli\*.cs

CSharpCliTest.exe: CliTest.cs csharpcli.dll
	csc /debug /reference:csharpcli.dll /out:CSharpCliTest.exe CliTest.cs

zip: clean
	cd ..
	-del gigabase.zip
	zip -r gigabase.zip gigabase

copyzip: zip
	copy gigabase.zip d:

